function plusOne(digits: number[]): number[] {
	const len = digits.length;
	let toAdd = 1;

	for (let i = len - 1; i >= 0; i--) {
		const newVal = digits[i] + toAdd;
		digits[i] = newVal % 10;
		toAdd = Math.floor(newVal / 10);

		if (!toAdd) {
			break;
		}
	}

	if (toAdd) {
		digits.unshift(toAdd);
	}

	return digits;
}
